import compose from "koa-compose";
import validator from "src/validators";

// 接口验证
const verification = async (ctx: Context, next: Next) => {
  const path = ctx.request.path;
  const name = path.replace("/api/", "").replace("/", "_");
  await validator(ctx, next, name as API.SchemaKey);
};

// 使用 koa-compose 组合中间件
const middlewares = compose([verification]);

export default middlewares;
